using System.Collections.Generic;
using UnityEngine;

public class SkillAreaCollider : MonoBehaviour
{
    public List<GameObject> targetsIn = new();
    public List<GameObject> targetsStay = new();
    public List<GameObject> targetsOut = new();

    public GameObject owner;
    //public bool inSkill;

    public void Clear()
    {
        targetsIn.Clear();
        //targetsStay.Clear();
        targetsOut.Clear();
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!collision.GetComponent<Damageable>()) return;

        if (collision.GetComponent<Damageable>().teamType
            != owner.GetComponent<Damageable>().teamType)
        {
            targetsIn.Add(collision.gameObject);
            targetsStay.Add(collision.gameObject);
        }
    }

    private void OnTriggerStay2D(Collider2D collision)
    {
        ;
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (!collision.GetComponent<Damageable>()) return;

        if (collision.GetComponent<Damageable>().teamType
            != owner.GetComponent<Damageable>().teamType)
        {
            targetsOut.Add(collision.gameObject);
            targetsStay.Remove(collision.gameObject);
        }
    }
}
